<%=include('./common/commonLinks.html')(it, opt)%>
<%=include('./common/header.html')(it, opt)%>
<main id="content" role="main">
    <div class="wrap">
        <div id="applyContainer" class="formContainer">

            <form id="applyForm" class="form-horizontal form-wrap" role="form">
                <h3 class="applyTitle">
                    <% if (it.apply.name) {%>
                    业务编辑
                    <% } else { %>
                    新业务申请
                    <%}%>
                </h3>
                <div class="form-group">
                    <label  class="col-sm-4 control-label">业务名称 <span style="color: red">*</span></label>
                    <div class="col-sm-6">
                        <input  type="text" class="apply-name form-control" placeholder="申请业务名" value="<%=it.apply.name%>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">业务URL <span style="color: red">*</span></label>
                    <div class="col-sm-6">
                        <input
                            type="url"
                            class="apply-url form-control"
                            placeholder="业务url"
                            value="<%=it.apply.url%>"
                        >
                        <p class="input-tips">
                            上报请求的 referer 与该 url 不匹配将被拒绝<br>
                            eg: <b>http://www.qq.com/(绝对匹配)</b> 和 <b>*.qq.com</b> 格式<br>
                            如果不希望服务器做 referer 检查, 请填写 <b>*</b><br>
                        </p>
                    </div>


                </div>

                <!--<div class="form-group">-->
                <!--<label class="col-sm-4 control-label">通知邮箱</label>-->
                <!--<div class="col-sm-6">-->
                <!--<input type="email" class="apply-mail form-control"  placeholder="通知邮箱">-->
                <!--</div>-->
                <!--</div>-->
                <div class="form-group">
                    <label  class="col-sm-4 control-label" >业务描述&nbsp;  </label>
                    <div class="col-sm-6">
                        <textarea  placeholder="业务描述" class="apply-description form-control" rows="4"><%=it.apply.description%></textarea>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-4 control-label">IP 限制</label>
                    <div class="col-sm-6">
                        <%
                            try {
                                it.apply.blacklist = JSON.parse(it.apply.blacklist || {})
                            }catch(e){
                                it.apply.blacklist = {}
                            }
                            var blacklistIPStr =  it.apply.blacklist.ip ? it.apply.blacklist.ip.join(',') : ''
                            var blacklistUAStr =  it.apply.blacklist.ua ? it.apply.blacklist.ua.join(',') : ''
                        %>

                        <input
                            class="apply-name form-control apply-blacklist-ip"
                            placeholder="拦截指定IP上报"
                            value="<%= blacklistIPStr %>" type="text" />
                        <p class="input-tips">
                            格式如下：
                            <code>127.0.0.5,132.5.3.*,132.4.* </code>
                        </p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">userAgent 限制</label>
                    <div class="col-sm-6">

                        <input
                            class="apply-name form-control apply-blacklist-ua"
                            placeholder="拦截指定userAgent上报"
                            value="<%= blacklistUAStr %>" type="text" />
                        <p class="input-tips">
                            格式如下：
                            <code> Baiduspider,Googlespider  </code>
                        </p>
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-6">
                        <button class="col-sm-3 btn btn-primary apply-submit" >
                            <% if (it.apply.name) {%>
                            编辑
                            <% } else { %>
                            申请
                            <%}%>
                        </button>
                        <button type="reset" class="col-sm-offset-1 col-sm-3 btn btn-default" >重置</button>
                    </div>
                    <% if (it.apply.name) {%>
                     <input type="hidden" value="<%=it.apply.id%>" name="applyId" id="applyId">
                    <% }  %>
                </div>
            </form>
        </div>



    </div>
</main>

<%=include('./common/footer.html')(it)%>
<script src="/static/entry.apply.js"></script>
</body>

</html>
